package com.atguigu.springcloud.service;

import com.atguigu.springcloud.entities.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author : yangxudong
 * @Description :
 * @Date : 下午2:01 2018/8/3
 */
@Component
public class ClientDeptServiceFallbackFactory implements FallbackFactory<ClientDeptService> {
    @Override
    public ClientDeptService create(Throwable throwable) {
        return new ClientDeptService() {
            @Override
            public boolean add(Dept dept) {
                return false;
            }

            @Override
            public Dept get(Long id) {
                return new Dept().setDeptno(id).setDname(id + "对应的服务可能暂停服务")
                        .setDb_source("this is no dept database");
            }

            @Override
            public List<Dept> list() {
                return null;
            }
        };
    }
}
